package com.whnk.web.controller.pm;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.whnk.common.annotation.Log;
import com.whnk.common.base.AjaxResult;
import com.whnk.common.enums.BusinessType;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.pm.domain.WowInfo;
import com.whnk.pm.service.IWowInfoService;

/**
 * 节假日加班登记 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-07-25
 */
@Controller
@RequestMapping("/pm/wowInfo")
public class WowInfoController extends BaseController
{
    private String prefix = "pm/wowInfo";
	
	@Autowired
	private IWowInfoService wowInfoService;
	
	@RequiresPermissions("pm:wowInfo:view")
	@GetMapping()
	public String wowInfo()
	{
	    return prefix + "/wowInfo";
	}
	
	/**
	 * 查询节假日加班登记列表
	 */
	@RequiresPermissions("pm:wowInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WowInfo wowInfo)
	{
		startPage();
        List<WowInfo> list = wowInfoService.selectWowInfoList(wowInfo);
		return getDataTable(list);
	}
	
	/**
	 * 新增节假日加班登记
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存节假日加班登记
	 */
	@RequiresPermissions("pm:wowInfo:add")
	@Log(title = "节假日加班登记", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WowInfo wowInfo)
	{		
		return toAjax(wowInfoService.insertWowInfo(wowInfo));
	}

	/**
	 * 修改节假日加班登记
	 */
	@GetMapping("/edit/{wowId}")
	public String edit(@PathVariable("wowId") Integer wowId, ModelMap mmap)
	{
		WowInfo wowInfo = wowInfoService.selectWowInfoById(wowId);
		mmap.put("wowInfo", wowInfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存节假日加班登记
	 */
	@RequiresPermissions("pm:wowInfo:edit")
	@Log(title = "节假日加班登记", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WowInfo wowInfo)
	{		
		return toAjax(wowInfoService.updateWowInfo(wowInfo));
	}
	
	/**
	 * 删除节假日加班登记
	 */
	@RequiresPermissions("pm:wowInfo:remove")
	@Log(title = "节假日加班登记", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wowInfoService.deleteWowInfoByIds(ids));
	}
	
	/**
	 * 查看详细信息
	 * 
	 * @param wowId
	 * @param mmap
	 * @return
	 */
	@RequiresPermissions("pm:wowInfo:detail")
    @GetMapping("/detail/{wowId}")
    public String detail(@PathVariable("wowId") Integer wowId, ModelMap mmap)
	{
		WowInfo wowInfo = wowInfoService.selectWowInfoById(wowId);
		mmap.put("wowInfo", wowInfo);
        return prefix + "/detail";
    }
}
